
const nodemailer = require('nodemailer');

// create reusable transporter object using SMTP transport
const transporter = nodemailer.createTransport({
    'host': 'smtpdm.aliyun.com',
    'port': 465,
    'secureConnection': true, // use SSL
    'auth': {
        'user': 'account@mail.amcforu.com', // user name
        'pass': 'AmcforuMail123' // password
    }
});


const sender = (toEmail, subject, html) => {
    const opts = {
        from: 'AMCFORU<account@mail.amcforu.com>',
        to: toEmail,
        // bcc: 'JeezLee<450994392@qq.com',
        subject,
        html
    };

    transporter.sendMail(opts, (error, info) => {
        // --TODO:此处做邮件发送失败记录处理，写入本地文件
        if (error) {
            return console.log(error);
        }
        console.log('Message sent: ' + info.response);
    });
};


module.exports = sender;

sender('450994392@qq.com', 'test', 'This is a test email.' + new Date());
